<?
$smarty=new Smarty();
if(!ANTIHACK) die("ANTIHACK...");
$today_date=date("d-m-Y",time());$today_time[0]=strtotime($today_date);$today_time[1]=$today_time[0]+86400;
$data=array(
	"nameact"=>"Thông tin chung",
);$view=query("select count(id) as tt from logs where time>=$today_time[0] and time<$today_time[1]");$fview=fetch($view);$data[view]=$fview[tt];$p=query("select count(id) as ttp from post where time>=$today_time[0] and time<$today_time[1]");$fp=fetch($p);$data[post]=$fp[ttp];
$start=$today_time[0];$i=0;$data[view_h][max]=0;$data[view_h][min]=99999999999;$data[view_h][avg]=round($data[view]/24.00,2);while($i<13){	if($i>0) $data[view_h][0].=",";$end=$start+7200;$view_h=query("select count(id) as tth from logs where time>=$start and time<$end");$fview_h=fetch($view_h);if($fview_h[tth]> $data[view_h][max]) $data[view_h][max]=$fview_h[tth];if($fview_h[tth]< $data[view_h][min]) $data[view_h][min]=$fview_h[tth];$data[view_h][0].=$fview_h[tth];$i++;$start=$end;}$cat=query("SELECT count( `post`.`id` ) AS nums,`post`.`parent`,name FROM post,menu where `post`.`parent`=`menu`.`id` GROUP BY `post`.`parent` ORDER BY `nums` DESC limit 5");$total=0;$i=0;$color=array("#F7464A","#336699","#339933","#edf261","#cc6633","#666666");

while($fcat=fetch($cat))
{
	$total+=$fcat['nums'];
	$fcat["color"] = $color[$i];
	$data['cat'][]=$fcat;
	$i++;
}
$gpost=query("select * from post");
$allpost=numrows($gpost);
$data['cat'][]=array(
	"nums" => $allpost-$total,
	"parent" => 0,
	"name" => "Khác",
	"color" =>$color[$i],
);

$smarty->assign("data",$data);
$smarty->display("home.htm");
?>